#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int B;
int a[N];
char f(int x) {
  if (x <= 9)
    return '0' + x;
  else
    return 'A' + x - 10;
}
string change(int x, int b) {
  string res;
  while (x) res += f(x % b), x /= b;
  reverse(res.begin(), res.end());
  return res;
}
bool check(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> B;
  rep(i, 1, 300) {
    string s = change(i, B);
    string t = change(i * i, B);
    if (check(t)) cout << s << ' ' << t << endl;
  }
  return 0;
}